import React, { Component } from 'react'
import axios from 'axios'
import styles from '../components/list.module.css'
const textobj={
  'yes':'是',
  'no':'否'
}

export class Xiang extends Component {
  constructor(props) {
    super(props)
    this.state = {
       obj:{}
    }
  }
  componentDidMount(){
    console.log(this.props.match.params.id);
    axios.get('/getxiang',{
      params:{
        id:this.props.match.params.id
      }
    }).then(res=>{
      console.log(res.data);
      this.setState({
        obj:res.data
      })
    })
  }
  render() {
    const {match}=this.props
    const {obj}=this.state
    return (
      
      <div>
        <img src={obj.img} alt="" />
        <p>{obj.name}</p>
        <p>{obj.title}</p>
        <button className={styles[obj.text]}>{textobj[obj.text]}</button>
      </div>
    )
  }
}

export default Xiang